package com.example.userlist.util;

import lombok.Data;

import java.util.List;

/**
 * @ProjectName: springboot3_music
 * @Package: com.niit.util
 * @ClassName: Result
 * @description: 封装分会数据
 * @version: 1.0
 */
@Data
public class Result<T> {

    private String code;
    private String msg;
    private List<T> datas;

    private T data;

    public Result() {
    }
    public Result(List<T> datas) {
        this.datas = datas;
    }
    public Result(T data) {
        this.data = data;
    }

    public static <T>Result<T> success(){
        Result<T> result=new Result<T>();
        result.setCode("200");
        result.setMsg("成功");
        return result;
    }




    public static <T>Result<T> success(List<T> datas){
        Result<T> result=new Result<>(datas);
        result.setCode("200");
        result.setMsg("成功~~~");
        return result;
    }

    public static <T>Result<T> success(T data){
        Result<T> result=new Result<>(data);
        result.setCode("200");
        result.setMsg("成功~~~");
        return result;
    }



    public static <T>Result<T> success(String code,String msg,List<T> datas){
        Result<T> result=new Result<>(datas);
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }

    public static <T>Result<T> success(String code,String msg,T data){
        Result<T> result=new Result<>(data);
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }

    public static <T>Result<T> error(String code,String msg){
        Result<T> result = new Result<T>();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }

}
